<?php

class PaymentReviewsController extends AppController {

    var $name = 'PaymentReviews';

    public function index($payment_id) {
        $this->PaymentReview->recursive = 0;
        $payment_reviews = $this->PaymentReview->find('all', array('conditions' => array('PaymentReview.payment_id' => $payment_id), 'fields' => array('PaymentReview.id', 'PaymentReview.fecha', 'PaymentReview.observacion', 'User.nombre', 'User.primer_apellido', 'User.segundo_apellido')));
        $this->set('payment_reviews', $payment_reviews);
        $this->set('payment_id', $payment_id);
    }

    function add($payment_id) {
        if (empty($this->data)) {
            $this->data['PaymentReview']['user_id'] = $this->Auth->user('id');
            $this->data['PaymentReview']['payment_id'] = $payment_id;
        } else {
            if ($this->PaymentReview->saveAll($this->data)) {
                $this->redirect(array('controller' => 'PaymentReviews', 'action' => 'index', $payment_id));
            } else {
                $this->Session->setFlash('Error guardando datos');
            }
        }
    }

}

?>
